package cn.tj.student.web.servlet;

import cn.tj.student.dao.StudentDao;
import cn.tj.student.dao.impl.StudentDaoImpl;
import cn.tj.student.pojo.Student;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/queryOne")
public class QueryOne extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取请求中的id
        String id = req.getParameter("id");//刚才通过get传递的key
        StudentDao studentDao=new StudentDaoImpl();
        Student student = studentDao.queryOne(Long.valueOf(id));
        //将学生对象存到作用域
        req.setAttribute("student",student);
        //转发到学生修改页面
        req.getRequestDispatcher("student_update.jsp").forward(req,resp);
    }
}
